@extends('http.app')

@section('content')
    <form id="form1" method="post" accept-charset="UTF-8" class="form-horizontal">

        <div class="box-body" style="">

            <div class="fields-group" style="">

                <div class="form-group  ">

                    <label for="title" class="col-sm-2  control-label">标题</label>

                    <div class="col-sm-8">

                        <div class="input-group">

                            <span class="input-group-addon"><i class="fa fa-pencil fa-fw"></i></span>

                            <input type="text" id="title" name="title" value="" class="form-control title" placeholder="输入 标题">


                        </div>

                    </div>
                </div>
                <div class="form-group  " style="">

                    <label for="content" class="col-sm-2  control-label">内容</label>

                    <div class="col-sm-8" style="">

                        <!-- 加载编辑器的容器 -->
                        <script id="container" name="content" type="text/plain">
                            这里写你的初始化内容
                        </script>
                        <!-- 配置文件 -->
                        <script type="text/javascript" src="/vendor/ueditor/ueditor.config.js"></script>
                        <!-- 编辑器源码文件 -->
                        <script type="text/javascript" src="/vendor/ueditor/ueditor.all.js"></script>
                        <!-- 实例化编辑器 -->
                        <script type="text/javascript">
                            var ue = UE.getEditor('container');
                        </script>

                    </div>
                </div>

            </div>

        </div>
        <!-- /.box-body -->

        <div class="box-footer">

            {{csrf_field()}}
            <div class="col-md-4">
            </div>

            <div class="col-md-4">
                <div class="btn-group pull-right">
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </div>
        </div>

        <!-- /.box-footer -->
    </form>


    <script>

        $('#form1').on('submit', function (event) {

            event.preventDefault();

            var form = $(this);

            $.post('/m/add',form.serialize(),function(res){
                if (res.status_code) {
                    alert(res.message)
                } else {
                    alert(res.message)
                }
            });
        });

    </script>
@endsection